package com.dapeis.service;

import java.io.IOException;
import java.security.InvalidParameterException;
import java.util.Date;
import java.util.HashMap;
import java.util.Iterator;
import java.util.List;
import java.util.Map;
import java.util.SortedMap;
import java.util.TreeMap;

import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest;

import org.apache.http.client.ClientProtocolException;
import org.apache.http.client.methods.CloseableHttpResponse;
import org.apache.http.client.methods.HttpPost;
import org.apache.http.entity.StringEntity;
import org.apache.http.impl.client.CloseableHttpClient;
import org.apache.http.impl.client.HttpClients;
import org.apache.http.util.EntityUtils;
import org.aspectj.weaver.ast.Or;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.aop.ThrowsAdvice;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import tk.mybatis.mapper.entity.Example;
import tk.mybatis.mapper.entity.Example.Criteria;

import com.ag.core.base.Pager;
import com.ag.core.exception.SysTipsException;
import com.ag.core.utils.AgAssert;
import com.ag.dao.DBService;
import com.ag.dao.IDao;
import com.ag.utils.DateUtils;
import com.ag.utils.DictionarySettingUtils;
import com.ag.utils.NumberUtils;
import com.dapeis.core.utils.DBConfigUtils;
import com.dapeis.core.utils.MessagePushConfig;
import com.dapeis.core.utils.RequirementConfig;
import com.dapeis.core.utils.StylistConstants;
import com.dapeis.dao.IOrderExtMapper;
import com.dapeis.dao.IOrderMapper;
import com.dapeis.domain.Collocation;
import com.dapeis.domain.Coupons;
import com.dapeis.domain.Plan;
import com.dapeis.domain.Order;
import com.dapeis.domain.Requirement;
import com.dapeis.domain.Shop;
import com.dapeis.domain.User;
import com.dapeis.exception.VisitLimitException;
import com.dapeis.exception.order.OrderExistCollocationException;
import com.dapeis.pay.swiftpass.config.SPPayConfig;
import com.dapeis.pay.swiftpass.util.MD5;
import com.dapeis.pay.swiftpass.util.SPPayUtil;
import com.dapeis.pay.swiftpass.util.SignUtils;
import com.dapeis.pay.swiftpass.util.XmlUtils;
import com.dapeis.service.order.OrderFlow;
import com.dapeis.service.order.ProgramFlow;
import com.dapeis.service.order.RequirementFlow;
import com.dapeis.service.order.ServiceFlow;
import com.dapeis.tx.push.UserFinishServerNoticeText;

/**
 * 
 * Title:OrderService.java OrderService Description:
 * 
 * @author yuanyong
 * @date 2017年5月5日 下午1:57:03 Email: hzyuanyong@126.com
 *
 */

@Service
public class OrderService extends DBService<Order> {

    final Logger logger = LoggerFactory.getLogger(getClass());

    @Resource
    IOrderMapper mapper;
    @Resource
    IOrderExtMapper orderExtMapper;
    @Resource
    JPushService jpushService;
    @Resource
    TIMService timService;
    @Resource
    MoneyLogService moneyLogService;
    @Resource
    CouponsService couponsService;
    @Resource
    RequirementService requirementService;
    @Resource
    UserService userService;
    @Resource
    ShopService shopService;

    @Override
    protected IDao<Order> getIDao() {
	return mapper;
    }

    /**
     * 更新订单使用优惠券不用付款
     * 
     * @param order
     * @return
     */
    public boolean userCouponsOrder(Order order) {
	order.setPayState(StylistConstants.Order.PayStatus.PAY_SUCCESS);
	order.setPayTime(new Date().getTime() / 1000);
	order.setState(StylistConstants.Order.Status.PAY_SUCCESS);
	return updateByPrimaryKeySelective(order) > 0;
    }

    /**
     * 检查该需求是否生成过订单 true 存在订单 false 不存在订单
     * 
     * @param requirement
     * @return
     */
    public boolean checkExitsOrderWithRequiremnt(Requirement requirement) {
	Example example = new Example(Order.class);
	Criteria criteria = example.createCriteria();
	criteria.andEqualTo(Order.PROPERTY_LINKID, requirement.getId());
	criteria.andEqualTo(Order.PROPERTY_TYPE,
		StylistConstants.Order.Type.REQUIREMENT);
	return selectCountByExample(example) > 0;
    }

    /**
     * 需求生成订单 requirement ,id,type
     * 
     * @param requirement
     * @param user
     * @return
     */
    @Transactional
    public Order createOrderRequirement(Requirement requirement, User user) {

	Order order = new Order();
	order.setLinkId(requirement.getId());
	Integer originaPrice = null;
	// 此处需要判断该需求时候是用户从搭配师主页点击服务进来的
	if (NumberUtils.isValid(requirement.getShopId())) {
	    Shop shop = shopService.selectByPrimaryKey(requirement.getShopId());
	    originaPrice = shop.getPrice();
	    order.setCollocationId(shop.getCollocationId());
	} else {
	    // 系统配置的价格
	    originaPrice = getRequirementOriginalPrice(requirement.getType());
	}
	order.setOriginalPrice(originaPrice);
	order.setTransactionPrice(originaPrice);
	order.setPayChannel(StylistConstants.PayChannel.SWIFTPASS);
	order.setPayState(StylistConstants.Order.PayStatus.WAIT_PAY);
	order.setRecordCreateTime(new Date().getTime() / 1000);
	order.setType(StylistConstants.Order.Type.REQUIREMENT);
	order.setUserId(user.getId());
	order.setState(StylistConstants.Order.Status.WAIT_PAY);
	order.setId(createOrderId());
	order.setSource(StylistConstants.OrderSource.WEIXIN_USER);
	boolean result = mapper.insertSelective(order) > 0;
	if (result) {
	    logger.info("创建需求订单成功{}", order.getId());
	    return order;
	}
	throw new SysTipsException("创建订单失败");
    }

    /**
     * 使用优惠券
     * 
     * @param orderId
     * @param couponsId
     * @return
     */
    public Order updateOrder(Order order, Integer couponsId) {
	Coupons coupons = couponsService.selectByPrimaryKey(couponsId);
	AgAssert.notNull(coupons, SysTipsException.class, "无效的优惠券信息");
	AgAssert.isTrue(
		(coupons.getStatus() == StylistConstants.Coupons.status.NORMAL),
		SysTipsException.class, "该优惠券已使用或已过期");
	Integer couponsPrice = coupons.getPrice();
	order.setTransactionPrice(order.getOriginalPrice() - couponsPrice);
	order.setCouponsId(coupons.getId());
	boolean result = updateByPrimaryKeySelective(order) > 0;
	if (result) {
	    // 更新优惠券状态
	    if (null != order.getCouponsId()) {
		Coupons dbCoupons = couponsService.selectByPrimaryKey(order
			.getCouponsId());
		dbCoupons.setStatus(StylistConstants.Coupons.status.USED);
		dbCoupons.setUsedTime(new Date().getTime() / 1000);
		dbCoupons.setOrderId(order.getId());
		couponsService.updateByPrimaryKeySelective(dbCoupons);
	    }
	    if (order.getTransactionPrice() == 0) {
		//如果支付价格与原始价格相同(无需付款),则更新订单状态为已付款
		userCouponsOrder(order);
	    }
	    return order;
	}
	throw new SysTipsException("更新咨询订单信息失败!");
    }

    /**
     * 创建打赏订单
     * 
     * @param plan
     * @param user
     * @return
     */
    public Order createOrderPlan(Plan plan, Integer userId, Integer money) {
	Order order = new Order();
	order.setLinkId(plan.getId());
	/* 处理money */
	order.setOriginalPrice(money);
	order.setTransactionPrice(money);
	order.setPayChannel(StylistConstants.PayChannel.SWIFTPASS);
	order.setPayState(StylistConstants.Order.PayStatus.WAIT_PAY);
	order.setRecordCreateTime(new Date().getTime() / 1000);
	order.setType(StylistConstants.Order.Type.AWARD_PROGRAM);
	order.setUserId(userId);
	order.setCollocationId(plan.getCollocationId());
	order.setState(StylistConstants.Order.Status.WAIT_PAY);
	order.setId(createOrderId());
	order.setSource(StylistConstants.OrderSource.WEIXIN_USER);
	mapper.insertSelective(order);
	logger.info("创建打赏订单成功{}", order.getId());
	return order;
    }

    /**
     * 查询该方案下用户未付款的订单
     * 
     * @param planId
     * @param userId
     * @return
     */
    public Order getPlanOrder(Integer planId, Integer userId) {
	Example example = new Example(Order.class);
	Criteria criteria = example.createCriteria();
	criteria.andEqualTo(Order.PROPERTY_LINKID, planId);
	criteria.andEqualTo(Order.PROPERTY_USERID, userId);
	criteria.andEqualTo(Order.PROPERTY_TYPE,
		StylistConstants.Order.Type.AWARD_PROGRAM);
	criteria.andEqualTo(Order.PROPERTY_STATE,
		StylistConstants.Order.Status.WAIT_PAY);
	return selectOneByExample(example);
    }

    /**
     * 创建预付订单
     * 
     * @param request
     * @param order
     * @param user
     * @return
     */
    public Map createUnified(HttpServletRequest request, Order order, User user) {
	String param = initSPPayParam(request, order, user);
	return doSwfitPayRequest(param);
    }

    /**
     * 抢单操作
     * 
     * @param orderId
     * @param collocationId
     * @param request
     * @return
     */
    @Transactional
    public boolean task(Long orderId, Integer collocationId) {
	Order order = selectForLock(orderId);
	if (order.getCollocationId() != null) {
	    throw new OrderExistCollocationException();
	}
	OrderFlow orderFlow = getFlow(order.getType());
	orderFlow.check(order, StylistConstants.Order.Status.PAY_SUCCESS);
	order.setCollocationId(collocationId);
	order.setState(orderFlow.next(order.getState()));
	order.setTaskTime(new Date().getTime() / 1000);
	updateByPrimaryKeySelective(order);
	// 收支明细
	moneyLogService.task(order);
	boolean result = timService.addFriend(collocationId, order.getUserId());
	logger.info("collocationId:" + collocationId + ",userId:"
		+ order.getUserId() + ",添加好友结果:" + result);
	return true;
    }

    /**
     * 服务完成 用户和搭配师都可以发起服务完成
     * 
     * @param orderId
     * @param collocationId
     */
    @Transactional
    public boolean service(Long orderId, Integer collocationId, Integer userId) {
	Order order = selectForLock(orderId);
	AgAssert.notNull(order, SysTipsException.class, "查询不到订单 orderId:"
		+ orderId);
	OrderFlow orderFlow = getFlow(order.getType());
	orderFlow.check(order, StylistConstants.Order.Status.SERVICE);
	boolean wxUserDo = false;
	if (null == collocationId && null != userId) {

	    // 微信端点击发起服务
	    AgAssert.isTrue(userId == order.getUserId(),
		    VisitLimitException.class, "无权查看!");
	    wxUserDo = true;
	}
	if (null != collocationId && null == userId) {
	    // 搭配师发起服务
	    AgAssert.isTrue(collocationId == order.getCollocationId(),
		    VisitLimitException.class, "无权查看！");
	}
	order.setState(orderFlow.next(order.getState()));
	order.setServerFinshTime(new Date().getTime() / 1000);
	updateByPrimaryKeySelective(order);
	// 收入明细
	moneyLogService.finshService(order);
	shopService.serverFinishAddNum(order);//增加搭配师服务购买次数
	couponsService.doOrderFinishCoupons(order, order.getUserId());
	User user = userService.selectByPrimaryKey(order.getUserId());
	if (wxUserDo) {// 推送消息
	    jpushService.pushMessage(
		    order.getCollocationId(),
		    new UserFinishServerNoticeText(user.getNickName(), order
			    .getId()));
	}
	return true;
    }

    /**
     * 申请退款接口
     * 
     * @param orderId
     * @return
     */
    @Transactional
    public boolean refund(Long orderId, Integer userId) {
	// 先锁定数据库,查询订单状态是否还在发布中
	Order order = selectForLock(orderId);
	AgAssert.notNull(order, SysTipsException.class, "查询不到订单 orderId:"
		+ orderId);
	AgAssert.isTrue(order.getUserId() == userId, VisitLimitException.class,
		"不能操作别人的订单.");
	OrderFlow orderFlow = getFlow(order.getType());
	orderFlow
		.check(order,
			com.dapeis.core.utils.StylistConstants.Order.Status.PAY_SUCCESS);
	Map resultMap = doSwfitPayRequest(initRefundOrderParam(order,
		createRefundNo(order)));
	if (SPPayUtil.checkResut(resultMap)) {
	    order.setRefundNo(resultMap.get("refund_id").toString());
	    order.setState(StylistConstants.Order.Status.REFUND);
	    order.setRefundCreateTime(new Date().getTime() / 1000);
	    order.setPayState(StylistConstants.Order.PayStatus.WAIT_REFUND);
	    updateByPrimaryKeySelective(order);
	    return true;
	}
	return false;
    }

    /**
     * true 成功 false 失败
     * 
     * @param orderId
     * @return
     */
    public boolean queryRefundResult(Long orderId) {
	Order order = selectForLock(orderId);
	AgAssert.notNull(order, SysTipsException.class, "查询不到订单 orderId:"
		+ orderId);
	Map resultMap = doSwfitPayRequest(initRefudeResultParam(order));
	if (SPPayUtil.checkResut(resultMap)) {
	    updateByPrimaryKeySelective(doPasertRefundQueryResutl(resultMap,
		    order));
	    return true;
	}
	return false;
    }

    /**
     * 解析退款查询数据
     * 
     * @param requestMap
     * @return
     */
    protected Order doPasertRefundQueryResutl(Map map, Order order) {
	if (map.containsKey("refund_count")) {
	    if (map.get("refund_count").toString().equalsIgnoreCase("1")) {
		// 可以一比订单分批次退款,系统暂处理全额退款
		String resultStatus = map.get("refund_status_0").toString();
		String refundTime = map.get("refund_time_0").toString();
		order.setRefundStatus(resultStatus);
		order.setRefundTime(DateUtils.parse(refundTime).getTime() / 1000);
		order.setPayState(StylistConstants.Order.PayStatus.REFUND);
	    }
	}
	return order;
    }

    /**
     * 订单查询
     * 
     * @param request
     * @param order
     * @return
     */

    public Map queryOrder(HttpServletRequest request, Order order) {
	return doSwfitPayRequest(initQueryParam(request, order));
    }

    /**
     * 关闭swfit 支付订单
     * 
     * @param order
     * @return
     */
    public boolean closeSwfitOrder(Order order) {
	Map resultMap = doSwfitPayRequest(initColosOrderParam(order));
	if (SPPayUtil.checkResut(resultMap)) {
	    logger.info("关闭订单：{} 结果:{}", order.getId().toString(),
		    resultMap.get("result_code"));
	}
	return closeOrder(order);
    }

    /**
     * 关闭系统订单
     * 
     * @param order
     * @return
     */
    public boolean closeOrder(Order order) {
	order.setState(StylistConstants.Order.Status.COLSED);
	order.setModifyTime(new Date().getTime() / 1000);
	return updateByPrimaryKeySelective(order) > 0;
    }

    /**
     * 威富通请求
     * 
     * @param param
     * @return
     */
    public Map doSwfitPayRequest(String param) {
	CloseableHttpClient client = null;
	CloseableHttpResponse response = null;
	Map<String, String> resultMap = null;
	String res = null;
	try {
	    String SPURL = SPPayConfig.req_url;
	    HttpPost httpPost = new HttpPost(SPURL);
	    StringEntity entityParams = new StringEntity(param,
		    SPPayConfig.charset);
	    httpPost.setEntity(entityParams);
	    httpPost.setHeader("Content-Type", "text/xml;charset=ISO-8859-1");
	    client = HttpClients.createDefault();
	    response = client.execute(httpPost);
	    if (response != null && response.getEntity() != null) {
		resultMap = XmlUtils.toMap(
			EntityUtils.toByteArray(response.getEntity()),
			SPPayConfig.charset);
		res = XmlUtils.toXml(resultMap);
		if (!SignUtils.checkParam(resultMap, SPPayConfig.key)) {
		    res = "验证签名不通过";
		} else {
		    if (SPPayUtil.checkResut(resultMap)) {
			res = "ok";
		    }
		}
	    } else {
		res = "操作失败";
	    }
	} catch (ClientProtocolException e) {
	    e.printStackTrace();
	} catch (IOException e) {
	    e.printStackTrace();
	} catch (Exception e) {
	    e.printStackTrace();
	}

	Map<String, String> result = new HashMap<String, String>();
	if ("ok".equals(res)) {
	    result = resultMap;
	} else {
	    result.put("status", "500");
	    result.put("msg", res);
	}
	return resultMap;

    }

    /**
     * 生成订单号(19位)
     * 
     * @return
     */
    private Long createOrderId() {
	return NumberUtils.parseLong(DateUtils.nowDate("yyMMddHHmmssSSS")
		+ NumberUtils.random(4));
    }

    /**
     * 生成退款单号
     * 
     * 
     * @return
     */
    private String createRefundNo(Order order) {
	return "refund_" + order.getId().toString();
    }

    /**
     * 获取需求价格
     * 
     * @param type
     * @return
     */
    public Integer getRequirementOriginalPrice(Integer type) {
	String initPrice = DictionarySettingUtils
		.getParameterValue(RequirementConfig.PRIC_INIT + "." + type);
	Integer price = new Integer(initPrice);
	return price;
    }

    /**
     * 组装SP预支付参数
     * 
     * @param request
     * @param order
     * @param user
     * @return
     */
    public String initSPPayParam(HttpServletRequest request, Order order,
	    User user) {
	SortedMap<String, String> paramMap = new TreeMap<String, String>();
	paramMap.put("service", SPPayConfig.Service_unified);
	paramMap.put("mch_id", SPPayConfig.mch_id);
	paramMap.put("out_trade_no", order.getId().toString());
	paramMap.put("sub_openid", user.getOpenSourceKey());// 测试时关闭
	paramMap.put("body", StylistConstants.getSPPayBody(order));
	paramMap.put("notify_url", SPPayConfig.notify_url);
	paramMap.put("mch_create_ip", "123.207.184.227");
	paramMap.put("nonce_str", String.valueOf(new Date().getTime()));
	paramMap.put("total_fee", order.getOriginalPrice().toString());
	paramMap.put("is_raw", SPPayConfig.RAW.YES);
	Map<String, String> params = SignUtils.paraFilter(paramMap);
	StringBuilder buf = new StringBuilder((params.size() + 1) * 10);
	SignUtils.buildPayParams(buf, params, false);
	String sign = MD5.sign(buf.toString(), "&key=" + SPPayConfig.key,
		SPPayConfig.charset);
	paramMap.put("sign", sign);
	return XmlUtils.parseXML(paramMap);
    }

    /**
     * 组装订单查询参数
     * 
     * @param request
     * @param order
     * @return
     */
    public String initQueryParam(HttpServletRequest request, Order order) {
	SortedMap<String, String> paramMap = new TreeMap<String, String>();

	paramMap.put("service", SPPayConfig.Service_Query_Order);
	paramMap.put("version", SPPayConfig.version);
	paramMap.put("charset", SPPayConfig.charset);
	paramMap.put("sign_type", SPPayConfig.sign_type);
	paramMap.put("mch_id", SPPayConfig.mch_id);
	paramMap.put("nonce_str", String.valueOf(new Date().getTime()));
	paramMap.put("out_trade_no", order.getId().toString());
	Map<String, String> params = SignUtils.paraFilter(paramMap);
	StringBuilder buf = new StringBuilder((params.size() + 1) * 10);
	SignUtils.buildPayParams(buf, params, false);
	String preStr = buf.toString();
	String sign = MD5.sign(preStr, "&key=" + SPPayConfig.key,
		SPPayConfig.charset);
	paramMap.put("sign", sign);
	return XmlUtils.parseXML(paramMap);
    }

    /**
     * 组装关闭订单参数
     * 
     * @param order
     * @return
     */
    public String initColosOrderParam(Order order) {
	SortedMap<String, String> paramMap = new TreeMap<String, String>();
	paramMap.put("service", "unified.micropay.reverse");
	paramMap.put("version", SPPayConfig.version);
	paramMap.put("charset", SPPayConfig.charset);
	paramMap.put("sign_type", SPPayConfig.sign_type);
	paramMap.put("mch_id", SPPayConfig.mch_id);
	paramMap.put("out_trade_no", order.getId().toString());
	paramMap.put("nonce_str", String.valueOf(new Date().getTime()));
	Map<String, String> params = SignUtils.paraFilter(paramMap);
	StringBuilder buf = new StringBuilder((params.size() + 1) * 10);
	SignUtils.buildPayParams(buf, params, false);
	String preStr = buf.toString();
	String sign = MD5.sign(preStr, "&key=" + SPPayConfig.key,
		SPPayConfig.charset);
	paramMap.put("sign", sign);
	return XmlUtils.parseXML(paramMap);
    }

    /**
     * 退款接口
     * 
     * @param order
     * @param refundId
     * @return
     */
    private String initRefundOrderParam(Order order, String refund_no) {
	SortedMap<String, String> paramMap = new TreeMap<String, String>();
	paramMap.put("service", "unified.trade.refund");
	paramMap.put("version", SPPayConfig.version);
	paramMap.put("charset", SPPayConfig.charset);
	paramMap.put("sign_type", SPPayConfig.sign_type);
	paramMap.put("mch_id", SPPayConfig.mch_id);
	paramMap.put("out_trade_no", order.getId().toString());
	paramMap.put("out_refund_no", refund_no);
	paramMap.put("total_fee", order.getTransactionPrice().toString());
	paramMap.put("refund_fee", order.getTransactionPrice().toString());
	paramMap.put("op_user_id", SPPayConfig.mch_id);
	paramMap.put("nonce_str", String.valueOf(new Date().getTime()));
	Map<String, String> params = SignUtils.paraFilter(paramMap);
	StringBuilder buf = new StringBuilder((params.size() + 1) * 10);
	SignUtils.buildPayParams(buf, params, false);
	String preStr = buf.toString();
	String sign = MD5.sign(preStr, "&key=" + SPPayConfig.key,
		SPPayConfig.charset);
	paramMap.put("sign", sign);
	return XmlUtils.parseXML(paramMap);
    }

    /**
     * 退款查询接口
     * 
     * @param order
     * @return
     */
    private String initRefudeResultParam(Order order) {
	SortedMap<String, String> paramMap = new TreeMap<String, String>();
	paramMap.put("service", "unified.trade.refundquery");
	paramMap.put("version", SPPayConfig.version);
	paramMap.put("charset", SPPayConfig.charset);
	paramMap.put("sign_type", SPPayConfig.sign_type);
	paramMap.put("mch_id", SPPayConfig.mch_id);
	paramMap.put("out_trade_no", order.getId().toString());
	paramMap.put("refund_id", "101510054425201706206283665439");
	paramMap.put("nonce_str", String.valueOf(new Date().getTime()));
	Map<String, String> params = SignUtils.paraFilter(paramMap);
	StringBuilder buf = new StringBuilder((params.size() + 1) * 10);
	SignUtils.buildPayParams(buf, params, false);
	String preStr = buf.toString();
	String sign = MD5.sign(preStr, "&key=" + SPPayConfig.key,
		SPPayConfig.charset);
	paramMap.put("sign", sign);
	return XmlUtils.parseXML(paramMap);
    }

    /**
     * 根据订单类型获取流程
     * 
     * @param orderType
     * @return
     */
    public OrderFlow getFlow(String orderType) {
	if (StylistConstants.Order.Type.REQUIREMENT.equalsIgnoreCase(orderType)) {
	    return new RequirementFlow();
	} else if (StylistConstants.Order.Type.AWARD_SERVE
		.equalsIgnoreCase(orderType)) {
	    return new ServiceFlow();
	} else if (StylistConstants.Order.Type.AWARD_PROGRAM
		.equalsIgnoreCase(orderType)) {
	    return new ProgramFlow();
	}

	throw new SysTipsException("不支持的订单类型:" + orderType);
    }

    /**
     * 分页查询
     * 
     * @param pager
     */
    public void doQueryOrderRefundResult(Pager pager) {
	List list = pager.getItemList();
	if (null != list && !list.isEmpty()) {
	    for (Iterator iterator = list.iterator(); iterator.hasNext();) {
		Order order = (Order) iterator.next();
		if (order.getState() == StylistConstants.Order.Status.REFUND
			&& order.getPayState() == StylistConstants.Order.PayStatus.WAIT_REFUND) {
		    doQueryOrderRefundResult(order);
		}
	    }
	}
    }

    /**
     * 单个订单查询
     * 
     * @param order
     */
    public void doQueryOrderRefundResult(Order order) {
	queryRefundResult(order.getId());
    }

    public IOrderExtMapper getOrderExtMapper() {
	return orderExtMapper;
    }

}
